/* eslint-disable */
const { Controller } = require('egg');

class FavoriteController extends Controller {
    //查看收藏列表
    async index() {
        const { ctx } = this;
        const { pageIndex, pageSize,keyword } = ctx.query
        const result = await ctx.service.collect.findList(pageIndex, pageSize,keyword )
        ctx.success(result, '查询收藏信息成功')
    }
    //新增收藏
    async create() {
        const { ctx } = this;
        const { user_id, outfit_id } = ctx.request.body;
        const result = await ctx.service.favorite.add({ user_id, outfit_id });
        ctx.success(result, '收藏成功');
    }

    //取消收藏
    async destory() {
        const { ctx } = this;
        const success = ctx.service.favorite.remove(ctx.params.id);
        if (success) {
            ctx.success(null, '收藏成功');
        } else {
            ctx.error('取消收藏失败');
        }
    }
}
module.exports = FavoriteController;